﻿using System.Collections.Generic;
using d3PrtDgn.Core.BaseData;
using d3PrtDgn.Data.Domain.Entity;

namespace d3PrtDgn.Data.IDAO
{
	/// <summary>
	/// Category  data access object interface
	/// </summary>
    public interface ICategoryDao : IBaseDao
	{
		/// <summary>
		/// Loads category by id
		/// </summary>
		/// <param name="catId">Category ID</param>
		/// <returns>Loaded category</returns>
		Category FindById(int catId);

		/// <summary>
		/// Parses string and loads category by it
		/// </summary>
		/// <param name="catId">Category ID</param>
		/// <returns>Loaded category</returns>
		Category FindById(string catId);

		/// <summary>
		/// Loads category by abbreviation
		/// </summary>
		/// <param name="abbrev">Abbreviation of category</param>
		/// <returns>Loaded category</returns>
		Category FindByAbbreviation(string abbrev);

		/// <summary>
		/// Saves category
		/// </summary>
		/// <param name="category">Category to save</param>
		/// <returns>Saved category</returns>
		Category Save(Category category);

		/// <summary>
		/// Saves or updates (if exists) category
		/// </summary>
		/// <param name="category">Category to save</param>
		/// <returns>Saved category</returns>
		Category SaveOrUpdate(Category category);

		/// <summary>
		/// Loads all categories
		/// </summary>
		/// <returns>Loaded categories</returns>
		IList<Category> FindAll();

		/// <summary>
		/// Loads tree of categories with specified root category
		/// </summary>
		/// <param name="root">Root category of tree data</param>
		/// <returns>Loaded categories</returns>
		IList<Category> GetTree(Category root);

		/// <summary>
		/// Deletes category
		/// </summary>
		/// <param name="category">Category to delete</param>
		void Detele(Category category);

		/// <summary>
		/// Checks if abbreviation is unique
		/// </summary>
		/// <param name="abbreviation">Abbreviation to check</param>
		/// <param name="id">Allowed duplicate abbreviation ID</param>
		/// <returns>Flag if category abbreviation is unique in context</returns>
		bool IsUnique(string abbreviation, int id);
	}
}
